<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<html>

<head>
<meta name="decorator" content="moduleEdit" />
	<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js" type="text/javascript"></script>
	<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
	<link href="${staticPath}/lib/chosen/1.1.0/chosen.min.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="${staticPath}/js/brand.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#supplierBrandForm").validate({
		submitHandler: function(form){
			Oosp_Loading('正在提交，请稍等...');
			returnCheckedNos();
			form.submit();
		},
		errorContainer: "#messageBox",
		errorPlacement: function(error, element) {
			$("#messageBox").text("输入有误，请先更正。");
			if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
				error.appendTo(element.parent().parent());
			} else {
				error.insertAfter(element);
			}
		}
		
	});
	//单选对话框
	var shopDialog = {
			service: "selectOneShopService",
			idField: "shopNos",
			nameField: "shopName",
			title: "门店选择对话框"
	};
	$("#shopDialog").Dialog(shopDialog);
	showShopList();
});

	function openWin(url){
		var returnValue = openTempleteSelector(url,600,550);
		if(returnValue.dataType == "supplier")
		{
			$("#supplierId").val(returnValue.supplierId);
			$("#supplierInfo").val(returnValue.supplierInfo);
		}else
		{
			$("#brandCateId").val(returnValue.brandCateId);
			$("#brandNo").val(returnValue.brandNo);
			$("#brandInfo").val(returnValue.brandInfo);
		}
	}
	
	function showShopList()
	{
		var id = $("#id").val();
		if(null == id || id.length < 1){
			id = "ALL";
		}
		loadShopData('/biz/brand/supplierBrand/'+id+'/getShopList');
	}
</script>
<style type="text/css">
h4{ border-bottom:1px dotted #ccc; padding-bottom:10px; margin:30px 0 15px; color:#b12028; font-size: 12px;}
</style>
</head>
<body>
<div class="Report_f">
           <div class="Report_f_1">
                <div class="Report_f_title_1">申请品牌合作</div>
                <ul class="nav nav-tabs Report_f_title_2">
                  <li class="active"><a href="#label_1" data-toggle="tab">基本信息</a></li>
                </ul>
			<!-- Tab panes -->
			<div class="tab-content Report_f_title_3">
                 <div class="tab-pane active" id="label_1">
                 <div class="Report_f_title_4">
        		<form:form id="supplierBrandForm" modelAttribute="supplierBrand" action="${contextPath}/biz/brand/supplierBrand/save" method="post"
					class="form-inline" role="form">
					<form:hidden path="id" id="id"/>
					<form:hidden path="checkinShopNos" id="checkinShopNos"/>
					<form:hidden path="supplierId" id="supplierId"/>
					<form:hidden id="brandCateId" path="brandCateId"/>
					<input type="hidden" id="navId" name="navId" value="${navId }"/>
					<tags:message content="${message}" />
                       <div class="f_2">	
                       		<c:if test="${currUserRole != 'SUPPLIER' }">
							 	<div class="form-group col-sm-6">
									<label for="brand.brandCname" class="col-sm-3 control-label f_4">供应商:</label>
									<div class="col-sm-9 f_6">
										<div class="input-group">
											<c:choose>
												<c:when test="${supplierBrand.id != null}">
													<input id="supplierInfo" name="supplierInfo" value="${supplierBrand.supplierCname}(${supplierBrand.supplierNo })" readonly="readonly" class="f_5 required"/>
												</c:when>
												<c:otherwise>
													<input id="supplierInfo" name="supplierInfo"  readonly="readonly" class="f_5 required"/>
												</c:otherwise>
											</c:choose>
										<span class="input-group-btn">
										<a  class="btn btn-default btn_3" href="#" onclick="openWin('${contextPath}/biz/brand/supplier/dialoglist')">选择</a>
										</span>
								    </div>
									</div>
								</div>
							</c:if>
							 <div class="form-group col-sm-6">
								<label for="brand.brandEname" class="col-sm-3 control-label f_4">品牌:</label>
								<div class="col-sm-9 f_6">
									<div class="input-group">
										<c:choose>
											<c:when test="${supplierBrand.id != null}">
												<input id="brandInfo" name="brandInfo" value="${supplierBrand.brandCname}(${supplierBrand.brandNo})/${supplierBrand.cateName}" readonly="readonly" class="f_5 required"/>
											</c:when>
											<c:otherwise>
												<input id="brandInfo" name="brandInfo" readonly="readonly" class="f_5 required"/>
											</c:otherwise>
										</c:choose>
									<span class="input-group-btn">
									<a class="btn btn-default btn_3" href="#" onclick="openWin('${contextPath}/biz/brand/brandcate/dialoglist')">选择</a>
									</span>
							    </div>
								</div>
							</div>
						</div>
                       <div class="f_2">
							<div class="form-group col-sm-6">
								<label for="brandProxyId" class="col-sm-3 control-label f_4">合作属性:</label>
								<div class="col-sm-9 f_6">
									<form:select id="brandProxyId" path="brandProxyId" class="f_5 required">
											<c:forEach items="${brandProxyList}" var="item">
												<form:option value="${item.id}">${item.attrName}</form:option>
											</c:forEach>
									</form:select>
								</div>
							</div>
					   </div>
					   <div class="f_2">
                            <div class="form-group col-xs-12">
                                 <label for="inputtext3" class="col-lb-1 control-label f_10">意向门店:</label>
							<div class="col-sm-10 col-lb-2 f_6">
								<table id="shopData" class="table table-bordered" >
								</table>
							</div>
                            </div>
                        </div>
					   <div class="f_3">
	                      <div class="form-group col-xs-12">
							<label for="remark" class="col-lb-1 control-label f_10">备注:</label>
							<div class="col-sm-10 col-lb-2 f_6">
								<form:textarea id="remark" htmlEscape="false" path="remark" class="form-control f_11"  maxlength="1000"/>
							</div>
						 </div>
						</div>
					<div class="f_12">
					     <button type="button" class="btn btn-danger btn_5 btn_right" onclick="history.go(-1)">返&nbsp;回</button>
					     <button type="submit" class="btn btn-success btn_5 btn_right">保&nbsp;存</button>
					</div>
			 		</form:form>
                   </div>
              </div>
		  </div>
	</div>	
</div>
<script type="text/javascript" src="${staticPath}/js/list.js"></script>
</body>
</html>